import type { IQuery, IResponse, TableResponse } from '@/api/config/types';
import axios from 'axios';

export interface DictData {
  dictId: string;
  dictValue: string;
  dictName: string;
  dictType: string;
  dictSort: number;
  status: string;
}
export interface DictOption {
  value: string;
  label: string;
}

const prefix = '/system/dict/data'; // 根据实际情况调整路径前缀

export const listDictData = (query: IQuery) => {
  return axios.get<TableResponse<DictData>>(`${prefix}/list`, { params: query });
};

export const getDictData = (id: string | number) => {
  return axios.get<IResponse<DictData>>(`${prefix}/${id}`);
};

export const addDictData = (data: DictData) => {
  return axios.post<IResponse>(`${prefix}`, data);
};

export const updateDictData = (data: DictData) => {
  return axios.put(`${prefix}`, data);
};

export const delDictData = (id: string | number) => {
  return axios.delete(`${prefix}/${id}`);
};

export const getDict = (dictType: string) => {
  return axios.get<IResponse<DictOption[]>>(`${prefix}/kv`, { params: { dictType } });
};
